// pages/component/tagSelecter/tagSelecter.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {

  },

  /**
   * 组件的初始数据
   */
  data: {
    type: "组件",
    selectedIndex:0,
    bottom_scroll_left:0,
    btn_background_color:"#ffffff",
    btns:[{"title":"全部","color":"#ffffff","left":0,"index":0,'state': ''},{"title":"待签约","color":"#222E44","left":172.5,"index":1,'state': '1'},{"title":"进行中","color":"#222E44","left":345,"index":2,'state': '2'},{"title":"已结束","color":"#222E44","left":517.5,"index":3,'state': '3'}],
  },

  /**
   * 组件的方法列表
   */
  methods: {
    selectIndex:function(event){
      let index = event.currentTarget.dataset.index;
      let state = event.currentTarget.dataset.state;
      if(index == this.data.selectedIndex){
        return;
      }
      var list = this.data.btns;
      var dic =  this.data.btns[index];
      for (var i in list) {
        var item = list[i];
        if(item.index == index){
            item.color = "#ffffff";
        }else{
            item.color = "#222E44";
        }
      }
      this.setData({
          btns:list,
          bottom_scroll_left:dic.left,
          selectedIndex:index,
      });
      var myEventDetail = {"state":state} // detail对象，提供给事件监听函数
      var myEventOption = {} // 触发事件的选项
      this.triggerEvent('myevent', myEventDetail, myEventOption)
    },
  }
})
